/**
* jquery 自定义扩展
* @ dhc
* @date 2015/09/28 
*/
//扩展validatebox
$.extend($.fn.validatebox.defaults.rules, {   
    equals: {   
        validator: function(value,param){   
            return value == $(param[0]).val();   
        },   
        message: '输入的值不一致'  
    },
    limitLength: {   
        validator: function(value, param){   
            return value.length >= param[0] && value.length <= param[1];   
        },   
        message: '输入的值必须为{0}-{1}个字符'  
    }, 
    maxLength: {
    	validator: function(value, param){   
            return value.length <= param[0];   
        },   
        message: '输入的值不能多于{0}个字符'  
    },
    minLength: {
    	validator: function(value, param){   
            return value.length >= param[0];   
        },   
        message: '输入的值不能少于{0}个字符'  
    },
    isNumber : {
    	validator : function(value,param){
    		var patrn="^[0-9]*$";
    		var regex = new RegExp(patrn);
            return regex.test(value);
    	},
    	message : '请输入数字'
    },
    number : {
    	validator: function(value, param){   
    		var patrn="^-?\\d{1,"+param[0]+"}(\\.\\d{0,"+param[1]+"})?$";
    		var regex = new RegExp(patrn);
            return regex.test(value);
    		//return false;
        },   
        message: '输入的值必须是数字,最大整数{0}位、小数{1}位' 
    },
    isemail : {
    	validator: function(value, param){   
    		var reg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{2,3}){1,2})$/;
    		var regex = new RegExp(reg);
    		return regex.test(value);
    	},   
    	message: '请输入正确的格式' 
    },
    mobile : {
    	validator: function(value, param){   
    		var reg = /^1[34578]\d{9}$/;
    		var regex = new RegExp(reg);
    		return regex.test(value);
    	},   
    	message: '请输入正确的手机号码'
    },
    isIpAddress : {
    	validator: function(value, param){   
    		var reg = /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/;
    		var regex = new RegExp(reg);
    		return regex.test(value);
    	},   
    	message: '请输入正确的IP地址'
    },
    isPhoneNumber : {
    	validator: function(value, param){   
    		//手机号码
    		var regMobile = /^1[34578]\d{9}$/;
    		var regexMobile = new RegExp(regMobile);
    		//座机号码
    		var regPhone = /^0[1-9]\d{1,2}-[1-9]\d{6,7}$/;
    		var regexPhone = new RegExp(regPhone);
    		
    		return (regexMobile.test(value)||regexPhone.test(value));
    	},   
    	message: '请输入正确的电话号码'
    },
    isNumberScope : {
    	validator: function(value, param){   
    		var patrn="^-?\\d+(\\.\\d{0,"+param[1]+"})?$";    		
    		var regex = new RegExp(patrn);
            var isReturn = regex.test(value);
            if(isReturn){
            	var val = parseFloat(value);
            	if(val < param[0] || val > param[1]){
            		isReturn = false;
            	}
            } 
            return isReturn;
    		//return false;
        },   
        message: '输入的值必须是数字,范围{0}~{1}、小数{2}位' 
    }
}); 




